﻿using System;
using GDIT.BLL;
using GDIT.Model;
using GDIT.Base.PageBaseHelper;

namespace GDIT.page.manage
{
    public partial class main : System.Web.UI.Page
    {

        private BUsers user = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(Session["UserName"].ToString()))
                {
                    PageBase.MessageBoxShowAndGo("检查到你还没有登录，请先登录，谢谢！", "~/page/manage/login.aspx", Page);
                    return;
                }
                if (!IsPostBack)
                {
                    this.lblUserName.Text = Session["UserName"].ToString();
                    this.lblRole.Text = getUserRole();
                    this.lblDepartment.Text = getUserDepartment();
                }
            }
            catch (Exception ex)
            {
                PageBase.MessageBoxShow("操作失败，原因：" + ex.Message.ToString(), Page);
            }
        }

        //得到用户的角色
        private string getUserRole()
        {
            user = new BUsers();
            return user.SelectRole(Session["UserName"].ToString());
        }
        //得到用户的部门
        private string getUserDepartment()
        {
            user = new BUsers();
            return user.SelectDepartment(Session["UserName"].ToString());
        }
    }
}